import { createPinia } from 'pinia';
import { createApp, defineAsyncComponent } from 'vue';

import router from './app-router';
import CommonService from './shared/services/common-service';

import './style.css';

const App = defineAsyncComponent(() => import('./App.vue'));

const app = createApp(App);
app.use(createPinia());
app.use(router);

if (!CommonService.isDevEnv) {
  // app-level error handler that captures errors from all descendent components.
  app.config.errorHandler = (err) => {
    console.error(`General error occured: ${err}`);
  };
}

app.mount('#app');